package com.leo;

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.QuadCurve;
import javafx.stage.Stage;

/**
 * @ClassName QuadCurveDemo
 * @Description 二次曲线
 * @Author wangss
 * @date 2020.07.04 16:55
 * @Version 1.0
 */
public class QuadCurveDemo extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {

        HBox hBox = new HBox(200);
        hBox.setAlignment(Pos.CENTER);

        AnchorPane pane = new AnchorPane();
        pane.setPrefWidth(200);
        pane.setPrefHeight(200);
        pane.setStyle("-fx-background-color: #A9A9A9");

        QuadCurve qc = new QuadCurve();
        qc.setStartX(0);
        qc.setStartY(100);

        qc.setEndX(200);
        qc.setEndY(100);

        qc.setControlX(100);
        qc.setControlY(0);

        qc.setFill(Color.RED);
        qc.setStrokeWidth(2);
        qc.setStroke(Color.BLUE);


        QuadCurve qc1 = new QuadCurve();
        qc1.setStartX(0);
        qc1.setStartY(100);

        qc1.setEndX(200);
        qc1.setEndY(100);

        qc1.setControlX(50);
        qc1.setControlY(0);

        qc1.setFill(Color.RED);
        qc1.setStrokeWidth(2);
        qc1.setStroke(Color.BLUE);

        pane.getChildren().addAll(qc, qc1);

        hBox.getChildren().addAll(pane);

        AnchorPane an = new AnchorPane();
        an.getChildren().add(hBox);
        AnchorPane.setTopAnchor(hBox, 50d);
        AnchorPane.setLeftAnchor(hBox, 50d);

        Scene scene = new Scene(an);
        primaryStage.setScene(scene);
        primaryStage.setHeight(1000d);
        primaryStage.setWidth(1500d);
        primaryStage.setAlwaysOnTop(true);
        primaryStage.show();
    }
}
